﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InternRegistration.Model
{
    class InternList
    {
        ObservableCollection<Intern> interns = new ObservableCollection<Intern>();

        internal void Add(Intern intern)
        {
            interns.Add(intern);
        }

        internal void Remove(Intern intern)
        {
            interns.Remove(intern);
        }

        internal Intern get(long id)
        {
            //Get the patients index in the collection
            int index = GetIndex(id);
            //If present then return the element
            if (index > -1)
                return interns[index];
            return null;
        }


        private int GetIndex(long id)
        {
            int index = -1;
            if (interns.Count > 0)
            {
                for (int i = 0; i < interns.Count; i++)
                {
                    if (interns[i].Id == id)
                    {
                        index = i;
                        break;
                    }
                }
            }
            return index;
        }


    }
}
